﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Nage.Algorithms.Solution;
using Nage.Algorithms.Population;

namespace Nage.Algorithms.Evolution
{
    /// <summary>
    /// Evolution abstract class. When derived, the user can
    /// define how population evolves in time
    /// </summary>
    /// <typeparam name="TSol">Type of the solution</typeparam>
    public abstract class Evolution<TSol> : IEvolution<TSol> where TSol : ISolution
    {
        #region Public properties

        /// <summary>
        /// Defines recombination transformation for each solution
        /// </summary>
        public ISolutionRecombination<TSol> Recombination { get; set; }

        /// <summary>
        /// Defines mutation transformation for each solution
        /// </summary>
        public ISolutionMutation<TSol> Mutation { get; set; } 

        #endregion

        #region Evolve

        /// <summary>
        /// Evolves the current population into the next generation by
        /// providing typical generation shift behaviour.
        /// </summary>
        /// <param name="population">Current population</param>
        /// <returns>Next generation population</returns>
        public abstract IPopulation<TSol> Evolve(IPopulation<TSol> population);

        #endregion

        #region RankPopulation
        /// <summary>
        /// Ranks the population
        /// </summary>
        public virtual void RankPopulation()
        {
        } 
        #endregion
    }
}
